﻿//	Copyright (c) 2012 Jonathan Loe
//
//	MIT license (http://en.wikipedia.org/wiki/MIT_License)
//
//	Permission is hereby granted, free of charge, to any person obtaining a copy
//	of this software and associated documentation files (the "Software"), to deal
//	in the Software without restriction, including without limitation the rights 
//	to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
//	of the Software, and to permit persons to whom the Software is furnished to do so, 
//	subject to the following conditions:
//
//	The above copyright notice and this permission notice shall be included in all 
//	copies or substantial portions of the Software.
//
//	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 
//	INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
//	PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 
//	FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
//	ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Security;

using Ordinaire;
using Ordinaire.Data;
using Ordinaire.Db;
using Ordinaire.Security.Data;

namespace Ordinaire.Security
{
    /// <summary>
    /// Exposes and updates membership user information in the membership data store.
    /// </summary>
    public class User
    {
        #region Variables

        /// <summary>
        /// The date and time when the user was added to the membership data store.
        /// </summary>
        private string name;

        /// <summary>
        /// The name of the membership provider that stores and retrieves user information for the membership user.
        /// </summary>
        private string providerName;

        /// <summary>
        /// The date and time when the user was added to the membership data store.
        /// </summary>
        private DateTime creationDate;

        /// <summary>
        /// The date and time when the user was last authenticated.
        /// </summary>
        private DateTime lastLoginDate;

        /// <summary>
        /// The date and time when the membership user was last authenticated or accessed the application.
        /// </summary>
        private DateTime lastActivityDate;

        #endregion

        #region Constructor

        /// <summary>
        /// Create new membership user object with the specified property values.
        /// </summary>
        /// <param name="name">the UserName string for the membership user</param>
        /// <param name="providerName">the ProviderName string for the membership user</param>
        /// <param name="creationDate">the CreationDate DateTime object for the membership user</param>
        /// <param name="lastLoginDate">the LastLoginDate DateTime object for the membership user</param>
        /// <param name="lastActivityDate">the LastActivityDate DateTime object for the membership user</param>
        public User(string name, string providerName, DateTime creationDate, DateTime lastLoginDate, DateTime lastActivityDate)
        {
            this.name             = name;
            this.providerName     = providerName;
            this.creationDate     = creationDate;
            this.lastLoginDate    = lastLoginDate;
            this.lastActivityDate = lastActivityDate;
        }

        #endregion

        #region Property methods

        /// <summary>
        /// Gets the date and time when the user was added to the membership data store.
        /// </summary>
        public DateTime CreationDate
        {
            get { return creationDate; }
        }

        /// <summary>
        /// Gets or sets the date and time when the membership user was last authenticated or accessed the application.
        /// </summary>
        public DateTime LastActivityDate
        {
            get { return lastActivityDate; }
        }

        /// <summary>
        /// Gets or sets the date and time when the user was last authenticated.
        /// </summary>
        public DateTime LastLoginDate
        {
            get { return lastLoginDate; }
        }

        /// <summary>
        /// Gets the name of the membership provider that stores and retrieves user information for the membership user.
        /// </summary>
        public string ProviderName
        {
            get { return providerName; }
        }

        /// <summary>
        /// Gets the logon name of the membership user.
        /// </summary>
        public string UserName
        {
            get { return name; }
        }

        #endregion
    }
}
